home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-06-08 | 9.2 KB | 349 lines | [TEXT/EDIT] |
- on openStack
- global force,intl -- intl
- put 0 into force
- hide message box
- put the seconds/86400 + 16480.5 + 5/24 into jd2
- put trunc(jd2+24000000) +1 into jd
- get the date
- -- intl to next widget
- if it contains "."
- then put true into intl
- else put false into intl
- convert it to dateItems
- if intl then
- repeat with i=1 to number of chars of it
- if char i of it = "." then put "," into char i of it
- end repeat
- put item 1 of it into d
- put item 2 of it into m
- else
- put item 2 of it into m
- put item 3 of it into d
- end if
- -- intl
- put false into val
- if m>4 and m<=10 then put true into val
- put trunc(jd-7*trunc(jd/7)) into w
- -- -1 added to correct for 1989 v. 1.53
- if m=4 and d>=w-1 then put true into val
- if m=10 and (d-w)>=25 then put false into val
- -- for v. 1.53...
- set hilite of bkgnd button "DST" to val
- if val then
- put "D" into char 3 of last word of cd fld coords of cd 1
- else
- put "S" into char 3 of last word of cd fld coords of cd 1
- end if
- push card
- if the number of this cd is 1 then
- put line 2 of card field "Algol" into ecl
- repeat
- if ecl > jd2 then exit repeat
- add 2.8673075 to ecl
- end repeat
- set numberFormat to "0.0"
- put "Next minimum of Algol occurs in" && (ecl-jd2)*24 &&┬
- "hours at JD=" into line 1 of card field Algol
- set numberFormat to "0.###"
- put ecl+2400000 after line 1 of card field Algol
- put ecl into line 2 of card field Algol
- end if
- end openStack
-
- function TJDDate
- global intl
- get the seconds
- add 86400+3600*(12+DSTcheck()) to it
- -- intl add global and if below
- convert it to long date
- if intl then
- put char 1 to (offset(".",second word of it)-1) of second word of it ┬
- && third word of it && last word of it into he
- else
- put char 1 to (offset(",",third word of it)-1) of third word of it ┬
- && second word of it && last word of it into he
- end if
- return he
- end TJDDate
-
- function getDate
- global intl
- get the seconds
- convert it to long date
- -- intl add global and if below
- if intl then
- put char 1 to (offset(".",second word of it)-1) of second word of it ┬
- && third word of it && last word of it into he
- else
- put char 1 to (offset(",",third word of it)-1) of third word of it ┬
- && second word of it && last word of it into he
- end if
- return he
- end getDate
-
- function getJDDate
- global intl
- get the seconds
- add 3600*(12+DSTcheck()) to it
- convert it to long date
- -- intl add global and if below
- if intl then
- put char 1 to (offset(".",second word of it)-1) of second word of it ┬
- && third word of it && last word of it into he
- else
- put char 1 to (offset(",",third word of it)-1) of third word of it ┬
- && second word of it && last word of it into he
- end if
- return he
- end getJDDate
-
- function getUTDate
- global intl
- get the seconds
- add 3600*(DSTcheck()) to it
- convert it to long date
- -- intl add global and if below
- if intl then
- put char 1 to (offset(".",second word of it)-1) of second word of it ┬
- && third word of it && last word of it into he
- else
- put char 1 to (offset(",",third word of it)-1) of third word of it ┬
- && second word of it && last word of it into he
- end if
- return he
- end getUTDate
-
- function DSTcheck
- get first word of line 4 of card field Coords of first cd
- if hilite of bkgnd button "DST"
- then put it-1 into temp
- else put it into temp
- return temp
- end DSTcheck
-
- function sgn x
- if x<0 then
- get -1
- else if x=0 then
- get 0
- else if x>0 then
- get 1
- end if
- return it
- end sgn
-
- on dayOfYear
- -- returns day, dayUT as number of day in year
- -- intl fix...
- global dayUT,day,daySecs,intl
- put the date into daysecs
- -- intl add global and if/repeat below
- if intl then
- repeat with i=1 to number of chars of daysecs
- if char i of daysecs = "." then put "/" into char i of daysecs
- end repeat
- end if
- convert daySecs to seconds
- put number of chars of the date into ndate
- put "12/31/" & (char ndate-1 to ndate of the date)-1 into Jan0
- convert Jan0 to seconds
- put (daySecs-Jan0)/86400 into day
- put (daySecs-Jan0+3600*DSTcheck())/86400 into dayUT
- end dayOfYear
-
- on cheb a,b,c
- global x,xa,xb
- put 2*x*a-b+c into temp
- put a into xb
- put temp into xa
- end cheb
-
- on UT
- global day,daySecs,x,xa,xb,m
- dayOfYear -- gets daySecs
- get ((the seconds-daySecs)/3600+DSTcheck())mod 24
- put trunc(it) into h
- put trunc(60*(it-h)) into m
- if m<10 then put "0" before m
- put "Universal Time = "& h &":" & m into line 1 of field 1
- put it into line 2 of field 1
- end UT
-
- on ST
- global day,daySecs,x,xa,xb,dayUT
- dayOfYear -- gets day
- put (dayUT-1)/183-1 into x
- put 0 into a
- put 0 into b
- put 7 into i
- repeat until i=0
- cheb a,b,word i+1 of card field "Sidereal Cheb" of card 1
- put xa into a
- put xb into b
- subtract 1 from i
- end repeat
- put xb into b2
- cheb a,b,word 1 of card field "Sidereal Cheb" of card 1
- get ((xa-b2)/2+((the seconds-daySecs)/3600+DSTcheck())*1.00273791-┬
- (line 2 of card field "coords" of card 1)/15+24) mod 24
- put trunc(it) into h
- put trunc(60*(it-h)) into m
- if m<10 then put "0" before m
- put "Sidereal Time = "& h &":" & m into line 1 of field 2
- put it into line 2 of field 2
- end ST
-
- on hm decv
- global it,h,m
- put trunc(it) into h
- put trunc(60*(it-h)) into m
- if decv then put abs(m) into m
- if m<10 then put "0" before m
- end hm
-
- on calc num,force
- set cursor to 1001
- -- calcs ra and dec, force =1 means do it anyway
- put pi/180 into fac
- global day,daySecs,x,xa,xb,dayUT,it,h,m,mode
- dayOfYear -- gets day,dayUT
- get line 3 of field 1
- put fac*(line 1 of card field "Coords" of card 1) into lat
- if (it=trunc(dayUT) and the optionkey is up) and force=0 then
- put line 5 of field 5 into dra
- put (line 6 of field 5)*fac into dec
- put line 3 of field 6 into arg
- else
- set cursor to 1002
- put trunc(dayUT) into line 3 of field 1
- put (dayUT+((the seconds-daySecs)/3600+DSTcheck())/24-1)/183-1 ┬
- into x
- put 0 into a
- put 0 into b
- put num into i
- repeat until i=0
- set cursor to busy
- cheb a,b,word i+1 of field 3
- put xa into a
- put xb into b
- subtract 1 from i
- end repeat
- put xb into b2
- cheb a,b,word 1 of field 3
- get ((xa-b2)/2+48) mod 24
- put it*15 into dra
- put dra into line 5 of field 5
- hm false
- put short name of this card &" R.A. = "& h &"h " & m &"m"into┬
- line 1 of field 5
- put 0 into a
- put 0 into b
- put num into i
- repeat until i=0
- set cursor to busy
- cheb a,b,word i+1 of field 4
- put xa into a
- put xb into b
- subtract 1 from i
- end repeat
- put xb into b2
- cheb a,b,word 1 of field 4
- get (xa-b2)/2
- put it*fac into dec
- put it into line 6 of field 5
- put empty into sign
- if it<0 and it>-1 then put "-" into sign
- if it>0 then put "+" into sign
- hm true
- put short name of this card&" Dec. = "&sign&h&"í "&m&"'" ┬
- into line 2 of field 5
-
- if "Sun" is in short name of this card then
- get (-.20791-sin(lat)*sin(dec))/(cos(lat)*cos(dec))
- put abs(atan(sqrt(1-it*it)/it)) into ang
- if -.20791<sin(lat)*sin(dec) then put pi-ang into ang
- put ang/fac/15 into delta
- put (dra/15+(line 2 of field 1)-line 2 of field 2+24-DSTcheck()) ┬
- mod 24 into arg
- get arg-delta
- put it into line 3 of card field 1
- hm false
- ampm
- put "Twilight begins at "& h &":" & m && mode into line 1 of┬
- cd fld 1
- get arg+delta
- put it into line 4 of cd fld 1
- hm false
- ampm
- put "Twilight ends at "& h &":" & m && mode into line 2 of ┬
- cd fld 1
- end if
- get -sin(lat)*sin(dec)/cos(lat)/cos(dec)
- put atan(sqrt(1-it*it)/it) into ang
- if dec>0 then
- add pi to ang
- end if
- put ang/fac/15 into delta
- put dra/15+line 2 of field 1-line 2 of field 2+24-DSTcheck()into arg
- get (arg-delta) mod 24
- put arg into line 3 of field 6
- put it into line 4 of field 6
- hm false
- ampm
- put short name of this card && "Rises at "& h &":" & m && mode ┬
- into line 1 of field 6
- get (arg+delta) mod 24
- put it into line 5 of field 6
- hm false
- ampm
- put short name of this card && "Sets at "& h &":" & m && mode into ┬
- line 2 of field 6
-
- set cursor to 1001
- end if
- -- calc alt and az of object
- put ((360+15*(line 2 of field 2)-dra) mod 360)*fac into LHA
- put cos(LHA)*sin(lat)-tan(dec)*cos(lat) into den
- get atanq(den,sin(LHA))
- put round(it/fac) into temp
- put sin(lat)*sin(dec)+cos(lat)*cos(dec)*cos(LHA) into sina
- if abs(sina)<1 then
- get round(atan(sina/(sqrt(1-sina*sina)))/fac)
- if it>0 then
- put "Az. = "& temp into line 3 of field 5
- put "Alt. = " & it into line 4 of field 5
- else
- if temp>180
- then put "W" into tem
- else put "E" into tem
- put "below " & tem & " horizon" into line 3 of field 5
- put empty into line 4 of field 5
- end if
- else
- beep
- end if
- set cursor to 1
- end calc
-
- function atanq x,y
- get atan(y/x)
- if y>0 then add pi to it
- if y/x<0 then add pi to it
- return it
- end atanq
-
- on ampm
- global h,mode,intl
- if intl then
- put empty into mode
- else
- put h into h2
- if h>11 then
- subtract 12 from h
- put "PM" into mode
- else
- put "AM" into mode
- end if
- if h=0 then put 12 into h
- end if
- end ampm